﻿<?php 
include("../safe.php"); 
include("../action_save.php");
$action=$_GET["action"];
$id=intval($_GET["id"]);
if($_POST['id']<>''){$ID_Dele=implode(",",$_POST['id']);}
$user_name=$_POST["user_name"];
$first_name=$_POST["first_name"];
$last_name=$_POST["last_name"];
$email=$_POST["email"];
$user_pass=$_POST["user_pass"];
$country=$_POST["country"];
$city=$_POST["city"];
$postcode=$_POST["postcode"];
$address=$_POST["address"];
$company_name=$_POST["company_name"];
$vat=$_POST["vat"];

// if($action=='add'){
// $sql = "INSERT INTO ph_user(user_name,user_pass,real_name,qq,tel,myserverqq,c_time,status,isVerified)VALUES('".$user_name."','".$user_pass."','".$real_name."','".$qq."','".$tel."','".$myserverqq."','".date("Y-m-d H:i:s",time())."','yes','yes')";
// mysql_query($sql,$conn);
// insertaction($_SESSION["managername"],"新增".$user_name,$conn);
// echo "<script language=JavaScript>\r\n";
// echo "location.href='list.php'\r\n";
// echo "</script>";
// }

if($action=='edit'){
	if(!empty($user_pass)){
		$sql = "update ph_user set email='".$email."',user_pass='".$user_pass."',first_name='".$first_name."',last_name='".$last_name."',country='".$country."',city='".$city."',postcode='".$postcode."',address='".$address."',company_name='".$company_name."',vat='".$vat."' where ID='".$id."'";
	}else{$sql = "update ph_user set email='".$email."',first_name='".$first_name."',last_name='".$last_name."',country='".$country."',city='".$city."',postcode='".$postcode."',address='".$address."',company_name='".$company_name."',vat='".$vat."' where ID='".$id."'";
        }

mysql_query($sql,$conn);
insertaction($_SESSION["managername"],"编辑用户:".$user_name,$conn);
echo "<script language=JavaScript>\r\n";
echo "alert('修改成功!');\r\n";
echo "location.href='list.php'\r\n";
echo "</script>";
}

if($action=='del'){
if($ID_Dele<>''){
$sql = "delete from ph_user where id in(".$ID_Dele.")";
mysql_query($sql,$conn);}
if($id<>''){
$sql = "delete from ph_user where id ='".$id."'";
mysql_query($sql,$conn);}
insertaction($_SESSION["managername"],"删除用户",$conn);
echo "<script language=JavaScript>\r\n";
echo "alert('删除成功!');\r\n";
echo "location.href='list.php'\r\n";
echo "</script>";
}
?>